import http from '@/api/axios';
import { ResPage, ResultData, User } from '@/api/types';
import { BASE_SERVICE } from '@/api/axios/config/servicePort';

export const systemLogin = (params: User.LoginForm) => {
	return http.post<User.LoginRes>(BASE_SERVICE + '/sys/oauth/login', params, { headers: { noAuth: true } });
};

export const systemLogout = () => {
	return http.get<ResultData>(BASE_SERVICE + '/sys/oauth/logout', {});
};

export const getUserInfo = () => {
	return http.get<User.SysUser>(BASE_SERVICE + '/sys/user/info', {});
};

export const getUserPageList = (queryParams: any, pageNum = 1, pageSize = 10) => {
	return http.post<ResPage<User.SysUser>>(BASE_SERVICE + '/sys/user/list/page?pageNum=' + pageNum + '&pageSize=' + pageSize, queryParams);
};

export const getSysLogLogList = (queryParams: any, pageNum = 1, pageSize = 10) => {
	return http.post<ResPage<User.SysLoginLog>>(BASE_SERVICE + '/sys/user/login/log/page?pageNum=' + pageNum + '&pageSize=' + pageSize, queryParams);
};

export const uploadAvatar = (formData: any) => {
	return http.post<ResultData>(BASE_SERVICE + '/sys/user/avatar/upload', formData);
};

export const updateUserInfo = (params: any) => {
	return http.put<ResultData>(BASE_SERVICE + '/sys/user/info', params);
};
